<template>
	<view>
		<u-sticky>
			<view style="padding:10rpx;background-color: white;">
				<u-search placeholder="请输入关键词搜索" v-model="query.name" @custom='deviceSearch'></u-search>
			</view>
		</u-sticky>
		<view @click="handelSelectDevice(item)" v-for='item in deviceList'
			style="padding:20rpx;border-bottom: 2rpx solid #eee">
			<view>{{item.device_name}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				query: {
					name: ''
				},
				deviceList: []
			}
		},
		created() {
			this.deviceSearch()
		},
		methods: {
			deviceSearch() {
				this.$http.post('/data/api.auth.User/deviceSearch', this.query).then(res => {
					this.deviceList = res.data
				})
			},
			handelSelectDevice(row) {
				uni.$emit('device_item', row)
				uni.navigateBack()
			}
		}
	}
</script>

<style>

</style>